﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmCompras.aspx.cs" Inherits="WEB.frmCompras" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .auto-style1 {
            height: 64px;
        }
        .auto-style2 {
            height: 2px;
        }
        .auto-style3 {
            height: 14px;
        }
        .auto-style4 {
            width: 132px;
        }
        .auto-style5 {
            height: 64px;
            width: 132px;
        }
        .auto-style6 {
            width: 21px;
        }
        .auto-style7 {
            width: 47px;
        }
        .auto-style8 {
            width: 112px;
        }
        .auto-style9 {
            height: 64px;
            width: 90px;
        }
        .auto-style10 {
            width: 90px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
     <div class="row col-lg-12">
       <div class="col-md-1">

    </div>
    <div class="col-md-9">

            <div class="panel panel-primary">
                <div class="panel-heading">
                    <label style="color:black">
                    <h3><b/>Información de la Compra</h3></label>
                </div>
                <div class="panel-body">
                    
                    
                    
                    <asp:UpdatePanel runat="server" ID="UpProveedor">
                        <ContentTemplate>
                            <table>
                                <tr>
                                    <td><label>RUC/DNI:</label></td>
                                    <td class="auto-style10"><asp:TextBox ID="txtRuc" CssClass="form-control" runat="server" Width="228px"/></td>
                                    <td class="auto-style4"><asp:Button runat="server" CssClass="btn btn-primary" ID="btnCargarProveedor" Text="Buscar" OnClick="btnCargarProveedor_Click"/> </td><td> </td><td> </td><td></td><td></td><td></td>
                                    <td><label>N° Compra:</label></td>
                                    <td colspan="2"><asp:TextBox ID="txtCodigo" CssClass="form-control"  runat="server" ReadOnly="True" Width="90px"/></td>
                                </tr>
                                <tr>
                                    <td class="auto-style1"><label>Proveedor:</label></td>
                                    <td class="auto-style9"><asp:TextBox ID="txtCliente" CssClass="form-control"  runat="server" Width="251px"/></td>
                                     <td class="auto-style5">&nbsp;</td>
                                    <td class="auto-style1">&nbsp;</td>
                                    <td class="auto-style1"> </td><td class="auto-style1"> </td><td class="auto-style1"> </td><td class="auto-style1"></td><td class="auto-style1"><b/><label>Fecha de registro:</label></td><td class="auto-style1" colspan="2"><b/>
                                        <asp:TextBox CssClass="form-control" data-format="dd/MM/yyyy hh:mm:ss" id="txtFecha" runat="server"/></td>
                                    <td class="auto-style1"></td>
                                    <td class="auto-style1">
                                        &nbsp;</td>
                                </tr>
                                <tr>
                                    <td><label>Dirección:</label></td>
                                    <td class="auto-style10"><asp:TextBox ID="txtDireccion" CssClass="form-control"  runat="server" Width="286px"/></td>
                                    <td rowspan="5" class="auto-style4"> </td><td rowspan="5"> </td><td rowspan="5"> </td><td rowspan="5"></td><td rowspan="5"></td><td rowspan="5"></td>
                                    <td rowspan="2"><b/><label>Tipo de pago:</label></b></td>
                                    <td class="auto-style6" rowspan="2">
                                        <asp:DropDownList ID="DropDownList1" runat="server">
                                            <asp:ListItem Value="credito">A credito</asp:ListItem>
                                            <asp:ListItem Value="contado">Al contado</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                    <td class="auto-style7" rowspan="2">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td></td>
                                    <td class="auto-style10"></td>
                                </tr>
                                <tr>
                                    <td rowspan="2">&nbsp;</td>
                                    <td rowspan="2" class="auto-style10">&nbsp;</td>
                                    <td><b/><label>Fecha de pago</label></td>
                                    <td class="auto-style3" colspan="2"><b/>
                                        <input type="text" CssClass="form-control"  data-format="dd/MM/yyyy hh:mm:ss" id="txtFecha0"/></td>
                                </tr>
                                <tr>
                                    <td><b/><label>Nro cuotas</label></td>
                                    <td class="auto-style3" colspan="2"><b/><asp:TextBox ID="txtDireccion0" CssClass="form-control"  runat="server" Width="51px"/>
    
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td class="auto-style10">&nbsp;</td>
                                    <td class="auto-style2"><b/><label>Total:</label></td>
                                    <td class="auto-style2" colspan="2"><b/><label>00.00</label></td>
                                </tr>
                            </table>
                            <br/>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnCargarProveedor" EventName="Click"/>
                        </Triggers>
                    </asp:UpdatePanel>
                    <br />
                    <table>
                        <tr>
                            <td><label>Criterio:</label></td>
                            <td class="auto-style8"><asp:TextBox ID="txtCriterio" CssClass="form-control"  placeholder="BUSCAR INSUMO/PRODUCTO" runat="server" Width="364px"/></td>
                            <td class="auto-style4"><asp:Button runat="server" CssClass="btn btn-default" Text="Buscar" ID="btnBuscar" Height="31px" Width="106px"/></td>
                         </tr>
                     </table>
                    <br/><br/>
                    
                    
                    <asp:UpdatePanel runat="server" ID="upInsumos">
						<ContentTemplate>
							<asp:ListView ID="lvInsumos"
								 ItemType="Box.Entities.Producto" SelectMethod="GetInsumos"
								runat="server" OnItemCommand="lvInsumos_ItemCommand">
								<EmptyDataTemplate>
									<b>No se han encontrado Insumos..!!</b>
								</EmptyDataTemplate>
								<LayoutTemplate>
									<table class="table table-bordered table-striped table-hover table-condensed">
										<thead>
											<tr>
												<th>#</th>
												<th>Descripción</th>
												<th>Precio</th>                                                
                                                <th>Und. Medida</th>												
												<th>Acciones</th>
											</tr>
										</thead>
										<tbody>
											<tr id="itemPlaceholder" runat="server"/>
										</tbody>
									 </table>
									<asp:DataPager ID="dpProductos" PagedControlID="lvInsumos" runat="server" PageSize="2">
										<Fields>
											<asp:NextPreviousPagerField
												ButtonType="Link"
												ShowFirstPageButton="True"
												ShowLastPageButton="True"
												ShowNextPageButton="True"
												ShowPreviousPageButton="True"
												/>
										</Fields>
									</asp:DataPager>
								</LayoutTemplate>
								<ItemTemplate>
									<tr>
										<th><%# Item.Id %></th>
										<th><%# Item.NombreProducto %></th>
										
										<th><%# Item.Precio %></th>
										<th>
											<asp:Button ID="btnAgregar"
												Text="Agregar" CommandName="AddDetalle"
												CommandArgument="<%# Item.Id %>"
												CssClass="btn btn-info btn-sm" runat="server"/>
										</th>
									</tr>
								</ItemTemplate>
							</asp:ListView>
						</ContentTemplate>
						<Triggers>
							<asp:AsyncPostBackTrigger ControlID="btnBuscar" EventName="Click"/>                            
						</Triggers>
					</asp:UpdatePanel>
                    
                    <legend class="label">Detalle Compra</legend>
                    
                    
                    <asp:UpdatePanel runat="server" ID="upDetalle">
								<ContentTemplate>
									<asp:ListView ID="lvDetCompra" runat="server" OnItemCommand="lvDetCompra_ItemCommand">
										<EmptyDataTemplate>
											<table class="table table-bordered table-striped table-hover table-condensed">
												<thead>
													<tr>
														<th>#</th>
														<th>Descripcion</th>
                                                        <th>Medida</th>
														<th>Cantidad</th>
														<th>Precio</th>
														<th>Monto</th>
														<th>Acciones</th>
													</tr>
												</thead>
												<tbody>
													<tr>
														<td colspan="6">
															<h3>No tiene insumos agregados a su detalle..!!</h3>
														</td>
													</tr>
												</tbody>
												<tfoot>
													<tr>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
														<td></td>
													</tr>
												</tfoot>
											</table>
										</EmptyDataTemplate>
										<LayoutTemplate>
											<table class="table table-bordered table-striped table-hover table-condensed">
												<thead>
													<tr>
														<th style="width: 20px;">#</th>													
														<th>Descripcion</th>
                                                        <th>Medida</th>
														<th>Cantidad</th>
														<th>Precio</th>
														<th>Monto</th>
														<th>Acciones</th>
													</tr>
												</thead>
												<tbody>
													<tr id="itemPlaceholder" runat="server"/>
												</tbody>
												<tfoot>
													<tr>
														<td>
															<asp:Button runat="server"
																ID="btnActualizarDetalle"
																Text="Actualizar Detalle"
																CommandName="ActualizarDetalle" />
														</td>
														<td></td>
														<td></td>
														<td><h3>Total:</h3></td>
														<td><h3><asp:Label ID="lblTotal" runat="server"></asp:Label></h3></td>
														<td></td>
													</tr>
												</tfoot>
											</table>
										</LayoutTemplate>                                
										<ItemTemplate>
											<tr>
												<td><%# Eval("Insumo.Id") %></td>
												<td><%# Eval("Insumo.DescripcionInsumo") %></td>
												<td><asp:TextBox runat="server" ID="txtCantidad" Text='<%# Bind("Cantidad") %>' Width="50px"/></td>
												<td><asp:TextBox runat="server" ID="txtPrecio" Text='<%# Bind("PrecioUnit") %>' Width="50px"/></td>
												<td><%# Eval("Monto") %></td>
												<td>
													<asp:Button ID="Button1" runat="server" Text="Quitar"
														CssClass="btn btn-danger btn-sm"
														CommandName="QuitarDetalle"
														CommandArgument='<%# Eval("IdInsumo") %>'/>
												</td>
											</tr>
										</ItemTemplate>
									</asp:ListView>
								</ContentTemplate>
								<Triggers>
									<asp:AsyncPostBackTrigger ControlID="lvDetCompra" EventName="ItemCommand"/>
									<asp:AsyncPostBackTrigger ControlID="lvInsumos" EventName="ItemCommand"/>
									<asp:AsyncPostBackTrigger ControlID="btnGuardar" EventName="Click"/>
								</Triggers>
							</asp:UpdatePanel>
                    
                    

                    

                </div>
                <div class="panel-footer">
                    <asp:Button runat="server" ID="btnGuardar" CssClass="btn btn-success" Text="Guardar" OnClick="btnGuardar_Click"/>
                    <asp:Button runat="server" ID="btnLimpiar" CssClass="btn bg-info" Text="Limpiar"/>
                   <%--  <asp:Button ID="Button7" runat="server" Text="Cancelar" CssClass="btn btn-danger"/>--%>
                </div>
            </div>
        </div>

     
     </div>
   </b>
   </asp:Content>
